// 导入三个添加页面
import AddInfo from "./add/AddInfo";
import AddProducts from "./add/AddProducts";
import Success from "./add/Success";
// 导入步骤条组件
import { Steps } from 'antd';
// 导入react useState
import {useState} from 'react'
import type { GroupInfoType} from '@/types/index';

function CreateGroupBuy() {
  // 定义团购信息默认值
  const defaultGroupBuyInfo:GroupInfoType = {   
    "name": "周六团购",
    "startTime": "2023-02-08",
    "endTime": "2023-02-09",
    "slogan": "比周五偏移一半",
    "showHome": 1,
    "homePic": '',
    "banner": '',
    "showType": "1",
    "target": "1",
    "limitBuy": 999,
    "shop": '',
    "deliverWay": '',
    "pickTime": "2023-02-07",
    "products": "12,13,14,15",
    "preTime": "2023-02-08",
    "tag": "4"
  }
  const [current, setCurrent] = useState(0);
  // 定义要创建的团购信息
  const [groupBuyInfo, setGroupBuyInfo] = useState<GroupInfoType>(defaultGroupBuyInfo);
  // 步骤条的数据
const items = [
  {
    title: '添加信息',
    content: <AddInfo 
     groupBuyInfo={groupBuyInfo} 
     setCurrent={setCurrent}
     setGroupBuyInfo={setGroupBuyInfo} />,    
  },
  {
    title: '添加商品',
    content: <AddProducts    
    groupBuyInfo={groupBuyInfo} 
    setCurrent={setCurrent}
    setGroupBuyInfo={setGroupBuyInfo}/>,
  
  },
  {
    title: '完成',
    content: <Success />,
     
  },
];

 
  // 步骤条发生变化时候更新current
  function onChange(current: number) {    
      // setCurrent(current);
  }
  return ( <div>
      <Steps current={current} labelPlacement="vertical" items={items} onChange={onChange} />
      {items[current].content}
  </div> );
}

export default CreateGroupBuy;